package com.jeeplus.modules.monitor.task;

import com.alibaba.fastjson.JSON;
import com.jeeplus.common.utils.SpringContextHolder;
import com.jeeplus.core.mapper.JsonMapper;
import com.jeeplus.modules.monitor.entity.InterfaceLog;
import com.jeeplus.modules.monitor.entity.ScheduleJob;
import com.jeeplus.modules.monitor.service.InterfaceLogService;
import com.jeeplus.modules.sys.utils.DictUtils;
import org.quartz.DisallowConcurrentExecution;
import com.jeeplus.modules.monitor.entity.Task;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;

@DisallowConcurrentExecution
public class TestTask extends Task{
	/*接收目录*/
	private String rcvPath="";
	/*日志*/
	protected Logger logger = LoggerFactory.getLogger(getClass());
	@Override
	public void run(ScheduleJob scheduleJob) {
		try {
			rcvPath=DictUtils.getDictValue("RCV","interface_path","");
			if(rcvPath.isEmpty())
			{
				logger.error("接收目录为空");
				return;
			}
			if(!new File(rcvPath).exists()){
				logger.info("接收目录不存在，准备创建!");
				new File(rcvPath).mkdirs();
			}
		}
		catch (Exception e){
			e.printStackTrace();
		}
		InterfaceLogService service=SpringContextHolder.getBean(InterfaceLogService.class);
		System.out.println(JsonMapper.toJsonString(service.get("2")));
		System.out.println(rcvPath);
		System.out.println("这是测试任务TestTask。");
		System.out.println(scheduleJob.getName());
		InterfaceLog interfaceLog=new InterfaceLog();
		interfaceLog.setSysName("USS");
		service.save(interfaceLog);
	}
	private void test(){
				try {
			Thread.sleep(1000*30);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

}
